package cn.jzk.aitest.DTO;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.ai.chat.messages.Message;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author jiangzk
 * 2025/4/22  下午5:35
 */
@Data
@NoArgsConstructor
public class MessageDTO implements Serializable {

    /**
     * 角色类型
     */
    private String role;

    /**
     * 对应的内容信息
     */
    private String content;

    public MessageDTO(Message message) {
        // 判断当前会话的类型
        switch (message.getMessageType()) {
            case USER:
                this.role = "user";
                break;
            case ASSISTANT:
                this.role = "assistant";
                break;
            case SYSTEM:
                this.role = "system";
                break;
            case TOOL:
                this.role = "tool";
                break;
            default:
                this.role = "";
                break;
        }
        this.content = message.getText();
    }

    @Serial
    private static final long serialVersionUID = 1L;
}
